<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:pe="http://primefaces.org/ui/extensions">
    <h:head>
        <title>#{bundle.fcperiod}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
        <h:form>
           <script type="text/javascript">  
                function handleSaveFcperiod(xhr, status, args) {  
                    if(args.validationFailed || !args.success) {  
                        jQuery('dialog').effect("shake", { times:3 }, 100);  
                    } else {  
                        dlgFcperiod.hide();  
                    }  
                }
                
                function handleDeleteFcperiod(xhr, status, args) {  
                    if(args.validationFailed || !args.success) {  
                        jQuery('dialog').effect("shake", { times:3 }, 100);  
                    } else {  
                        dlgConfirmation.hide();  
                    }  
                }
                
                function componenKeyPressFcperiod(e) {
                    var code = (e.keyCode ? e.keyCode : e.which);
                    if(code==13) {
                        submitBuslic.jq.click();
                        e.preventDefault();
                    }
                }
                
            </script>

            <p:toolbar>
                <p:toolbarGroup align="left">
                    <p:commandButton value="#{bundle.btnNew}"
                                     icon="ui-icon-document"
                                     action="#{fcperiodBean.newData()}"  
                                     oncomplete="dlgFcperiod.show()" process="@this"
                                     rendered="#{menuBean.cekButtonAccess(581,'INS;')}"
                                     update=":#{utilityBean.findClientId('displayFcperiod')}"> 
                    </p:commandButton>

                    <p:commandButton value="#{bundle.btnOpen}" oncomplete="dlgFcperiod.show()"
                                     icon="ui-icon-disk" 
                                     action="#{fcperiodBean.openData()}"
                                     rendered="#{menuBean.cekButtonAccess(581,'OPN;')}"
                                     update=":#{utilityBean.findClientId('displayFcperiod')}" > 
                    </p:commandButton>

                    <p:commandButton value="#{bundle.btnDelete}" icon="ui-icon-trash"
                                     onclick="dlgConfirmation.show()"
                                     rendered="#{menuBean.cekButtonAccess(581,'DEL;')}"/> 

                   <!-- <p:commandButton type="push" value="#{bundle.btnPrint}" icon="ui-icon-print"/> -->
                </p:toolbarGroup>
            </p:toolbar>
            <br />
            <p:dataTable var="fcperiod" value="#{fcperiodBean.fcperiods}" id="dtFcperiods"
                         selection="#{fcperiodBean.selectedData}" selectionMode="single" 
                         rowKey="#{fcperiod.fcperiodId}" resizableColumns="true"
                         paginator="true" rows="10" paginatorPosition="bottom" 
                         paginatorTemplate="#{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         rowsPerPageTemplate="5,10,15,30" >
                
                <p:column width="60" >
                    <f:facet name="header">#{bundle.year}</f:facet>
                    <h:outputText value="#{fcperiod.glyear}" />
                </p:column>
                <p:column width="60" >
                    <f:facet name="header">#{bundle.period}</f:facet>
                    <h:outputText value="#{fcperiod.glperiod}" />
                </p:column>
                <p:column width="70" >
                    <f:facet name="header">#{bundle.status}</f:facet>
                    <h:outputText value="#{fcperiod.periodStatus}" />
                </p:column>
                <p:column width="100" >
                    <f:facet name="header">#{bundle.closedBy}</f:facet>
                    <h:outputText value="#{fcperiod.closedBy}" />
                </p:column>
                <p:column width="60" >
                    <f:facet name="header">#{bundle.closingDate}</f:facet>
                    <h:outputText value="#{fcperiod.closingDate}" />
                </p:column>
            </p:dataTable>
          
            <p:confirmDialog message="#{bundle.confirmDelete}" appendToBody="true" 
                             header="#{bundle.confirmDeleteHeader}" severity="alert" widgetVar="dlgConfirmation">  
                <p:commandButton value="#{bundle.btnYes}" update="dtFcperiods" process="@this"
                                 oncomplete="handleDeleteFcperiod(xhr, status, args)"  
                                 actionListener="#{fcperiodBean.delete()}" />  
                <p:commandButton value="#{bundle.btnCancel}" onclick="dlgConfirmation.hide()" type="button" />   
            </p:confirmDialog> 
        </h:form >
            
            <p:dialog header="#{bundle.fcperiod}" widgetVar="dlgFcperiod" closable="true" dynamic="true" modal="true" appendToBody="true">
                <p:ajax event="close" immediate="true" listener="#{fcperiodBean.handleClose}"/>
                <h:form >
                <h:panelGrid id="displayFcperiod" columns="3" styleClass="addELIT">
                    <p:outputLabel value= "#{bundle.year}" for="fcyear" /><h:outputLabel value= ":" />
                    <pe:inputNumber value="#{fcperiodBean.insertedData.glyear}" maxValue="9999" id="fcyear" required="true" 
                                    style="width: 60px; text-align: right;" thousandSeparator="" decimalPlaces="0" />
                    
                    <p:outputLabel value="#{bundle.period}" for="fcmonth" /><h:outputLabel value= ":" />
                    <pe:inputNumber value="#{fcperiodBean.insertedData.glperiod}" maxValue="12" id="fcmonth" required="true" 
                                    style="width: 60px; text-align: right;" thousandSeparator="" decimalPlaces="0"/>
                                         
                    <h:outputLabel value= "#{bundle.status} " /><h:outputLabel value= ":" />
                    <p:selectOneRadio value="#{fcperiodBean.insertedData.periodStatus}" rendered="#{fcperiodBean.insertedData!=null}">
                        <f:selectItem itemLabel="#{bundle.fcpstatusOpen}" itemValue="O"/>
                        <f:selectItem itemLabel="#{bundle.fcpstatusClosed}" itemValue="C"/>
                    </p:selectOneRadio>
                                            
                    <h:outputLabel value= "#{bundle.closedBy}" /><h:outputLabel value= ":" />
                    <h:outputLabel rendered="#{fcperiodBean.insertedData!=null}" value="#{fcperiodBean.insertedData.closedBy}" />  
                                        
                    <h:outputLabel value= "#{bundle.closingDate} " /><h:outputLabel value= ":" />
                    <h:outputLabel rendered="#{fcperiodBean.insertedData!=null}" value="#{fcperiodBean.insertedData.closingDate}" />  
                </h:panelGrid>
                    
                <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR">
                    <f:facet name="footer">
                        <p:commandButton value="#{bundle.btnSave}" icon="ui-icon-disk" actionListener="#{fcperiodBean.save()}"
                                         update=":#{utilityBean.findClientId('dtFcperiods')}"  rendered="#{menuBean.cekButtonAccess(581,'UPD;')}"
                                         oncomplete="handleSaveFcperiod(xhr, status, args)"/>
                        <p:commandButton value="#{bundle.btnClose}" oncomplete="dlgFcperiod.hide()" process="@this" icon="ui-icon-document"/>
                    </f:facet>
                </h:panelGrid>
                    </h:form>
            </p:dialog> 
        
        </ui:composition>    
    </h:body>
</html>